<template lang="html">
  <div class="container">
    <!--导航头部begin-->
    <el-row>
      <el-col :span="24" class="header">
        <el-col :span="4" class="logo" :class="collapsed?'logo-collapse-width':'logo-width'">{{collapsed?'':sysName}}
        </el-col>
        <el-col :span="10">
          <div class="tools">
            <i class="fa fa-align-justify"></i>
          </div>
        </el-col>
        <el-col :span="4" class="userinfo">
          <el-dropdown trigger="hover">
            <span class="el-dropdown-link userinfo-inner">{{sysUserName}}</span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>我的消息</el-dropdown-item>
              <el-dropdown-item>设置</el-dropdown-item>
              <el-dropdown-item divided @click.native="logoutFun">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-col>
      </el-col>
    </el-row>
    <!--导航头部end-->
    <el-row  class="tac main">
      <!--左侧导航菜单start-->
      <el-col :span="4" class="lefNav">
        <el-menu  class="el-menu-vertical-demo" background-color="#545c64"
                  text-color="#fff"
                  active-text-color="#ffd04b" router>
          <template v-for="(item,index) in menuList" v-if="!item.hidden">
            <el-submenu :index="index+''" :key="index+''">
              <template slot="title"><i :class="item.iconCls"></i><span slot="title">{{item.name}}</span></template>
              <el-menu-item v-for="child in item.children" :index="child.path" :key="child.path"  v-if="!child.hidden">
                {{child.name}}
              </el-menu-item>
            </el-submenu>
          </template>
        </el-menu>
      </el-col>
      <!--左侧导航菜单end-->
      <!--内容区start-->
      <el-col :span="20">
        <section class="content-container">
          <div class="grid-content bg-purple-light">
            <el-col :span="24" class="breadcrumb-container">
              <strong class="title">{{$route.name}}</strong>
              <el-breadcrumb separator="/" class="breadcrumb-inner">
                <el-breadcrumb-item v-for="item in $route.matched" :key="item.path">
                  {{ item.name }}
                </el-breadcrumb-item>
              </el-breadcrumb>
            </el-col>
            <el-col :span="24" class="content-wrapper">
              <transition name="fade" mode="out-in">
                <router-view></router-view>
              </transition>
            </el-col>
          </div>
        </section>
      </el-col>
      <!--内容区end-->
    </el-row>
  </div>
</template>

<script>

export default {
  components: {},
  data () {
    return {
      sysName: '运营商后台',
      sysUserName: '',
      collapsed: false,
      menuList: []
    }
  },
  methods: {
    // 退出登录
    logoutFun: function () {
      var _this = this
      this.$confirm('确认退出吗?', '提示', {
        // type: 'warning'
      }).then(() => {
        sessionStorage.removeItem('user')
        _this.$router.push('/login')
      }).catch(() => {

      })
    }
  },
  created () {
    this.menuList = this.$router.options.routes.slice(1)
  },
  mounted () {
    var user = sessionStorage.getItem('user')
    if (user) {
      user = JSON.parse(user)
      this.sysUserName = user.username || ''
    }
  }
}
</script>

<style scoped lang="scss">
  .container {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
    .header {
      height: 60px;
      line-height: 60px;
      background: #545c64;
      color: #fff;
      .userinfo {
        text-align: right;
        padding-right: 35px;
        float: right;
        .userinfo-inner {
          cursor: pointer;
          color: #fff;
        }
      }
      .logo {
        height: 60px;
        font-size: 22px;
        padding-left: 40px;
        padding-right: 20px;

      }
      .logo-width {
        width: 175px;
      }
      .logo-collapse-width {
        width: 60px;
      }
      .tools {
        padding: 0 23px;
        width: 14px;
        height: 60px;
        line-height: 60px;
        /*cursor: pointer;*/
      }
    }
    .main {
      height: 100%;
      .lefNav{
        height: 100%;
        .el-menu{
          height: 100%;
        }
      }
      .content-container {
        flex:1;
        overflow-y: scroll;
        padding: 20px;
        .breadcrumb-container {
          .title {
            width: 200px;
            float: left;
            color: #475669;
          }
          .breadcrumb-inner {
            float: right;
          }
        }
        .content-wrapper {
          background-color: #fff;
          box-sizing: border-box;
        }
      }
    }
  }
</style>
